<?php /*a:3:{s:65:"D:\projects\original_admin\app\merchant\view\order\shop_back.html";i:1754751364;s:61:"D:\projects\original_admin\app\merchant\view\common\base.html";i:1752764603;s:63:"D:\projects\original_admin\app\merchant\view\common\header.html";i:1754830154;}*/ ?>
<!DOCTYPE html>
<html lang="zh-CN">

<head>
	<meta charset="UTF-8" />
	<meta name="renderer" content="webkit" />
	<meta name="force-rendering" content="webkit" />
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>管理系统</title>
	<script src="/static/merchant/js/jquery-min.js"></script>
	<link rel="stylesheet" href="/static/merchant/layui/css/layui.css">
	<script type="text/javascript" src="/static/merchant/layui/layui.js"></script>
	<link rel="stylesheet/less" type="text/css" href="/static/merchant/css/index.less" />
	<script src="/static/merchant/js/less.js"></script>
    
</head>
<body>
	<main class="CenterMain">
		<header class="Header">
    <div class="logo img_box">
        <img src="/static/merchant/images/logow.png">

    </div>
    <div class="top">
        <ul class="nav-buttons">
            <li id="toggle-btn">

                <span class="desktop-text layui-icon layui-icon-spread-left">
                </span>
                <span class="mobile-text">菜单</span>
            </li>
        </ul>
        <dl class="menu-btn">
            <a class="img_box ">
                <img src="/static/merchant/images/head1.png">
                <i class="msg"></i>
            </a>
            <a class="img_box">
                <img src="/static/merchant/images/head2.png">
            </a>
        </dl>
        <span class="hr"></span>
        <ul class="layui-nav">

            <li class="layui-nav-item" lay-unselect>
                <a href="javascript:;">
                    <img  src="<?php echo htmlentities((string) (isset($userInfo['shop_thumb']) && ($userInfo['shop_thumb'] !== '')?$userInfo['shop_thumb']:'/static/merchant/images/sign-user.png')); ?>" class="layui-nav-img">
                    <span><?php echo htmlentities((string) $userInfo['shop_name']); ?></span>
                </a>
                <dl class="layui-nav-child">
                    <!-- <dd><a href="account_info.html">个人信息</a></dd> -->
                    <dd><a href="/merchant/account_pwd.html">密码修改</a></dd>
                    <dd style="text-align: center;"><a href="/merchant/login_out">退出</a></dd>
                </dl>
            </li>
        </ul>
    </div>

</header>
<div class="Sidebar" id="sidebar">
    <ul class="menu">
        <li class="menu-item">
            <div lay-on="url" href="/" class="title">
                <div class="img img_box">
                    <img class="img1" src="/static/merchant/images/nav22.png">
                    <img class="img2" src="/static/merchant/images/nav21.png">
                </div>
                <span>商品管理</span>
                <!-- <i class="layui-icon layui-icon-right"></i> -->
            </div>
        </li>
        <li class="menu-item <?php if($routers == 'order/list' || $routers == 'order/shop_back' || $routers == 'order/review'): ?>  active <?php endif; ?>">
            <div class="title">
                <div class="img img_box">
                    <img class="img1" src="/static/merchant/images/nav32.png">
                    <img class="img2" src="/static/merchant/images/nav31.png">
                </div>
                <span>订单管理</span>
                <i class="layui-icon layui-icon-right"></i>
            </div>
            <dl    <?php if($routers == 'order/list' || $routers == 'order/shop_back' || $routers == 'order/review'): ?>  style="display: block;" <?php else: ?> style="display:none;" <?php endif; ?> >
                <dd>
                    <a href="/merchant/order.html"  <?php if($routers == 'order/list'): ?>  class="active" <?php endif; ?> >订单管理</a>
                </dd>
                <dd>
                    <a href="/merchant/shop_back.html" <?php if($routers == 'order/shop_back'): ?>  class="active" <?php endif; ?>>退货管理</a>
                </dd>
                <dd>
                    <a href="/merchant/review.html" <?php if($routers == 'order/review'): ?>  class="active" <?php endif; ?>>订单评价</a>
                </dd>

            </dl>

        </li>
        <li class="menu-item <?php if($routers == 'finance/finance_cash' || $routers == 'finance/finance_account' || $routers == 'finance/finance_log' || $routers == 'finance/finance_logs'): ?>  active <?php endif; ?>">
            <div class="title">
                <div class="img img_box">
                    <img class="img1" src="/static/merchant/images/nav42.png">
                    <img class="img2" src="/static/merchant/images/nav41.png">
                </div>
                <span>财务提现</span>
                <i class="layui-icon layui-icon-right"></i>
            </div>

            <dl  <?php if($routers == 'finance/finance_cash' || $routers == 'finance/finance_account' || $routers == 'finance/finance_log' || $routers == 'finance/finance_logs'): ?>  style="display: block;" <?php else: ?> style="display:none;" <?php endif; ?>>
                <dd>
                    <a  <?php if($routers == 'finance/finance_cash'): ?>  class="active" <?php endif; ?> href="/merchant/finance_cash.html">提现</a>
                </dd>
                <dd>
                    <a  <?php if($routers == 'finance/finance_logs'): ?>  class="active" <?php endif; ?> href="/merchant/finance_logs.html">记录</a>
                </dd>
            </dl>

        </li>
        <!-- <li class="menu-item ">
            <div class="title">
                <div class="img img_box">
                    <img class="img1" src="images/nav52.png">
                    <img class="img2" src="images/nav51.png">
                </div>
                <span>消息中心</span>
                <i class="layui-icon layui-icon-right"></i>
            </div>

        </li> -->
        <li class="menu-item <?php if($routers == 'store/store_info' || $routers == 'store/store_notice' || $routers == 'store/store_model'): ?>  active <?php endif; ?>">
            <div class="title">
                <div class="img img_box">
                    <img class="img1" src="/static/merchant/images/nav62.png">
                    <img class="img2" src="/static/merchant/images/nav61.png">
                </div>
                <span>店铺设置</span>
                <i class="layui-icon layui-icon-right"></i>
            </div>

            <dl <?php if($routers == 'store/store_info' || $routers == 'store/store_notice' || $routers == 'store/store_model'): ?>  style="display: block;" <?php else: ?> style="display:none;" <?php endif; ?>>
                <dd>
                    <a  <?php if($routers == 'store/store_info'): ?>  class="active" <?php endif; ?> href="/merchant/store_info.html">店铺信息 </a>
                </dd>
                <dd>
                    <a <?php if($routers == 'store/store_notice'): ?>  class="active" <?php endif; ?> href="/merchant/store_notice.html">店铺公告</a>
                </dd>
                <dd>
                    <a <?php if($routers == 'store/store_model'): ?>  class="active" <?php endif; ?>  href="/merchant/store_model.html">运费模板</a>
                </dd>
            </dl>

        </li>
    </ul>
</div>
		 
<style>
    .layui-form-label{
        width: 100px;
    }
</style>
<div class="Content" id="content">
    <div class="container">
        <!-- 搜索栏 -->
        <form class="layui-form search-form SearchCom " lay-filter="searchForm">
            <div class="OrderSearcItem">
                <!-- <div class="input-inline ">
                    <select name="category" lay-search lay-filter="category">
                        <option value="">商品分类</option>
                        <option value="1">定制实物</option>
                        <option value="2">设计原创</option>
                    </select>
                </div> -->

                <!-- <ul>
                    <a class="item active" href="">全部</a>

                    <a class="item " href="">退货</a>

                    <a class="item " href="">退款</a>

                    <a class="item " href="">退货退款</a>

                    <a class="item " href="">同意退款</a>

                    <a class="item " href="">拒绝退款</a>

                </ul> -->
                
                <ul id="statusTab">
                    <a class="item active" data-status="">全部</a>
                    <!-- <a class="item" data-status="0">退货</a> -->
                    <a class="item" data-status="1">退款</a>
                    <a class="item" data-status="2">退货退款</a>
                    <a class="item" data-status="3">同意退款</a>
                    <a class="item" data-status="4">拒绝退款</a>
                </ul>

                <div class="layui-form-item">

                    <div class="layui-input-wrap">
                        <div class="layui-input-prefix">
                            <i class="layui-icon layui-icon-search"></i>
                        </div>
                        <input type="text" placeholder="订单号/买家/商品名" class="layui-input">
                    </div>
                    <button class="layui-btn layui-btn-blue" style="margin-right: 20px;" lay-submit
                        lay-filter="search">查询</button>
                </div>

            </div>
        </form>

        <!-- 商品表格 -->
        <table class="layui-hide" id="productTable" lay-filter="productTable" lay-skin="line"></table>

    </div>
</div>
<script type="text/html" id="toolbarTpl">
    <div class="layui-btn-group">
        <button class="layui-btn layui-btn-normal" lay-event="batchDelete">批量删除</button>
    </div>
</script>
<script type="text/html" id="statusTpl">
    {{#  if(d.status === '待审核'){ }}
    <span class="layui-badge layui-bg-orange">{{ d.status }}</span>
    {{#  } else if(d.status === '已通过'){ }}
    <span class="layui-badge layui-bg-green">{{ d.status }}</span>
    {{#  } else if(d.status === '未通过'){ }}
    <span class="layui-badge layui-bg-red">{{ d.status }}</span>
    {{#  }}}
</script>

<script type="text/html" id="operateTpl">
    <div class="foot">

        <a class="btn-edit" lay-event="view">查看</a>
        {{#  if(d.status === '同意退款'){ }}
        
              <span>|</span>
          <a class="btn-edit" lay-event="deliver">退回物流</a>
        {{#  } else if(d.status === '退货'){ }}
        
               <span>|</span>
          <a class="btn-delete" lay-event="returnProcess">退货中</a>
        {{#  } }}


</div>
</script>

	</main>
</body>
<script  src="/static/merchant/js/index.js"></script>
<script src="/static/merchant/js/base.js"></script>
 
<script>
    changeTitleName('订单退款');
    
    layui.use(['table', 'form', 'laydate'], function () {
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;
        var laydate = layui.laydate;
        var $ = layui.$;
        var currentStatus = getUrlParam('status') || '';
        var currentKeyword = getUrlParam('keyword') || '';
        
        // 设置初始选中状态
        $('#statusTab .item').removeClass('active');
        $('#statusTab .item[data-status="' + currentStatus + '"]').addClass('active');
        // 渲染日期选择器
        laydate.render({
            elem: '#publishTime',
            range: true // 开启日期范围选择
        });

       
        var tableIns = table.render({
            elem: '#productTable',
            url: '/merchant/merchant-order-refund',
            height: 'full-100', // 关键参数：表格高度为页面高度减去100px
            where: {
                refund_status: currentStatus,
                keyword: currentKeyword
            },
            page: {
                limit: 10, // 每页17条 → 200/17 ≈ 12页（17*11=187，第12页13条）
                limits: [10, 17, 20, 30], // 包含17，默认选中17
                groups: 5, // 页码连续显示5个

                prev: '<',
                next: '>',
                layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'], // 显示总条数和跳转
                theme: '#1E9FFF',// 分页主题色
                jump: function (obj, first) {
                    console.log(obj.curr); // 得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); // 得到每页显示的条数

                    // 首次不执行
                    if (!first) {
                        // do something
                    }
                }
            },
            limit: 15,
            limits: [10, 15, 20, 30],
            cols: [
                [
                {
                    field: 'name',
                    title: '商品信息',
                    width: 400,
                    templet: function(d) {
                        return `
                        <div class="goods-container">
                            ${d.cart_detail.map(item => `
                                <div class="shopName">
                                    <div class="img img_100">
                                        <img src="${item.cart_info.thumb}" alt="${item.name}">
                                    </div>
                                    <div class="info">
                                        <p>${item.cart_info.productInfo.store_name}</p>
                                        <p>${item.cart_info.suk||''}</p>
                                        <p>×${item.cart_info.cart_num}</p>
                                    </div>
                                </div>
                            `).join('')}
                        </div>`;
                    }
                },
                { field: 'order_id', title: '订单号',width: 250 },
                { field: 'add_time', title: '下单时间',  },
                { field: 'nickname', title: '买家', },
                { 
                    field: 'real_name', 
                    title: '收货信息',
                    width: 350,
                    templet: function(d) {
                        return d.real_name + ' ' + d.user_address + '<br>' + d.user_phone;
                    } 
                },
                { field: 'pay_price', title: '总金额', },
                { field: 'total_num', title: '数量',  },
                {
                    field: 'status', 
                    title: '状态', 
                    width: 200, 
                    templet: function (d) {
                        var statusClass = '';
                        var statusName = '';
                        
                        switch (d.status) {
                            case 4: 
                                statusClass = 'layui-badge layui-bg-orange'; 
                                statusName = "申请退款";
                                break;
                            case 5: 
                                statusClass = 'layui-badge layui-bg-blue'; 
                                statusName = "退款通过"; 
                                break;
                            case 6: 
                                statusClass = 'layui-badge layui-bg-prop';
                                statusName = "退款拒绝"; 
                                break;
                            case 7: 
                                statusClass = 'layui-badge layui-bg-green'; 
                                statusName = "已完成";
                                break;
                            default:
                                statusClass = 'layui-badge'; 
                                statusName = "未知状态(" + d.status + ")";
                        }
                        
                        return '<span class="' + statusClass + '">' + statusName + '</span>';
                    }
                },
                {
                    //  fixed: 'right',
                    title: '操作',
                    width: 160,
                    toolbar: '#operateTpl'
                }
                ]
            ],
            done: function (res, curr, count) {
                console.log('表格渲染完成');
            }
        });
        // 状态标签点击事件
        $('#statusTab .item').on('click', function(e) {
            e.preventDefault();
            var status = $(this).data('status');
            
            // 更新选中状态
            $('#statusTab .item').removeClass('active');
            $(this).addClass('active');
            
            // 更新URL参数
            updateUrlParam('status', status);
            
            // 重新加载表格
            tableIns.reload({
                where: {
                    refund_status: status,
                    keyword: currentKeyword
                },
                page: { curr: 1 }
            });
        });
        form.on('submit(search)', function(data) {
            currentKeyword = data.field.keyword;
            
            // 更新URL参数
            updateUrlParam('keyword', currentKeyword);
            
            // 重新加载表格
            tableIns.reload({
                where: {
                    status: currentStatus,
                    keyword: currentKeyword
                },
                page: { curr: 1 }
            });
            return false;
        });
        // 监听表格复选框选择
        table.on('checkbox(productTable)', function (obj) {
            console.log(obj);
        });


        // 监听行工具事件
        table.on('tool(productTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {

                case 'view':
                    window.location.href = 'shop_back_info.html?id=' + data.order_id
                    break;
                case 'cancel':
                    layer.alert('确定要取消该订单吗？', {
                        title: '提示',
                        btn: ['确定', '取消'],
                        btn1: function () {

                        },
                        btn2: function () {
                        },
                        area: ['600px', '260px'],
                        skin: 'xieyiDialog'
                    });

                    break;
                case 'deliver':

                    window.location.href = 'shop_back_info1.html?id=' + data.id
                    break;
                case 'returnProcess':

                    break;
            }
        });

        // 监听搜索表单提交
        form.on('submit(search)', function (data) {
            table.reload('productTable', {
                where: data.field,
                page: {
                    curr: 1 // 重新从第 1 页开始
                }
            });
            return false;
        });

        // 监听添加商品按钮
        form.on('submit(addProduct)', function () {
            //layer.open({
            // type: 2,
            // title: '添加商品',
            //   content: 'shop_add.html',
            //   area: ['800px', '600px']
            //  });
            //  return false;
        });
        // 获取URL参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURI(r[2]); return null;
        }

        // 更新URL参数（不刷新页面）
        function updateUrlParam(key, value) {
            var url = window.location.href;
            var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
            var separator = url.indexOf('?') !== -1 ? "&" : "?";
            
            if (url.match(re)) {
                url = url.replace(re, '$1' + key + "=" + value + '$2');
            } else {
                url = url + separator + key + "=" + value;
            }
            
            history.pushState(null, null, url);
        }

        // 监听窗口大小变化，动态调整表格高度
        window.onresize = function () {
            table.resize('productTable');
        };
    });
</script>
>
</html>